//#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;

int su[100000005], cnt = 0, lp = 0;
bool vis[100000005];

void o_init(int l,int n) {
	for (int i = 2;i <= n;i++) {
		if (vis[i] == false)
		{
			su[++cnt] = i;
			if (i >= l && lp == 0)
				lp = cnt;
		}
		for (int j = 1;j <= cnt && su[j] * i <= n;j++){
			vis[su[j] * i] = true;
			if (i % su[j] == 0)
				break;
		}
	}
	return;
}

int main()
{
	int l, r;
	cin >> l >> r;
	o_init(l,r);
	for (int i = lp;i <= cnt;i++) {
		string tmp1 = to_string(su[i]);
		string tmp2 = tmp1;
		reverse(tmp1.begin(), tmp1.end());
		if (tmp1 == tmp2)
			cout << tmp2 << endl;
	}
	return 0;
}